home *** CD-ROM | disk | FTP | other *** search
/ Champak 132 (Alt) / Vol 132.iso / games / pupworld.swf / scripts / __Packages / Heroes / Timer.as < prev    next >
Encoding:
Text File  |  2011-06-09  |  1.2 KB  |  54 lines

  1. class Heroes.Timer extends MovieClip
  2. {
  3.    var currentTime_lz;
  4.    var myIntervalID;
  5.    var currentTime = 0;
  6.    var warningTime = 10;
  7.    function Timer()
  8.    {
  9.       super();
  10.    }
  11.    function addTime(extraTime)
  12.    {
  13.       if(this.currentTime != 0)
  14.       {
  15.          ┬º┬ºpush(this.play());
  16.       }
  17.       this.currentTime += extraTime;
  18.       this.currentTime_lz.setNumber(this.currentTime);
  19.    }
  20.    function setTime(newTime)
  21.    {
  22.       this.currentTime = newTime;
  23.       this.currentTime_lz.setNumber(this.currentTime);
  24.    }
  25.    function getTime()
  26.    {
  27.       return this.currentTime;
  28.    }
  29.    function start()
  30.    {
  31.       this.tick();
  32.       this.myIntervalID = setInterval(this,"tick",1000);
  33.    }
  34.    function stop()
  35.    {
  36.       clearInterval(this.myIntervalID);
  37.    }
  38.    function tick()
  39.    {
  40.       this.currentTime = this.currentTime - 1;
  41.       this.currentTime_lz.setNumber(this.currentTime);
  42.       if(this.currentTime == this.warningTime)
  43.       {
  44.          this._parent.level.follower.playSound("comeontimesticking");
  45.       }
  46.       if(this.currentTime == 0)
  47.       {
  48.          this._parent.level.player.stopRespondingToUser();
  49.          this._parent.outOfTime.gotoAndStop("show");
  50.          ┬º┬ºpush(this.stop());
  51.       }
  52.    }
  53. }
  54.